'''

database

'''
import sys
from PyQt5.QtWidgets import *
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from  PyQt5.QtSql import QSqlDatabase,QSqlQuery

def createDB():
    db=QSqlDatabase.addDatabase('QSQLITE')
    db.setDatabaseName('./sudent.db')
    if not db.open():
        QMessageBox.critical(None,("无法打开数据库"),("点击取消按钮退出"),QMessageBox.Cancel)

        return False
    query=QSqlQuery()
    query.exec_("create table student(id int primary key,name varchar (100),sex varchar(10) )")
    query.exec_("insert into  student values(1,'zs','男')")
    db.close()
    return  True
if __name__ == '__main__':
    app=QApplication(sys.argv)
    createDB()
    sys.exit(app.exec_())
